{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "f914aaad-8046-497c-955b-1a22df1861b1",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import lightgbm as lgb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "92750477-d6fb-4995-8ef4-9e45994e6870",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "train_data = pd.read_csv('工业场景下的服装生产力预测挑战赛公开数据/train.csv')\n",
    "test_data = pd.read_csv('工业场景下的服装生产力预测挑战赛公开数据/test.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "040b6f93-2a4d-404e-929d-44f2d9372685",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>team</th>\n",
       "      <th>smv</th>\n",
       "      <th>wip</th>\n",
       "      <th>over_time</th>\n",
       "      <th>incentive</th>\n",
       "      <th>idle_time</th>\n",
       "      <th>idle_men</th>\n",
       "      <th>no_of_style_change</th>\n",
       "      <th>no_of_workers</th>\n",
       "      <th>...</th>\n",
       "      <th>department_finishing</th>\n",
       "      <th>department_sweing</th>\n",
       "      <th>day_Monday</th>\n",
       "      <th>day_Saturday</th>\n",
       "      <th>day_Sunday</th>\n",
       "      <th>day_Thursday</th>\n",
       "      <th>day_Tuesday</th>\n",
       "      <th>day_Wednesday</th>\n",
       "      <th>targeted_score</th>\n",
       "      <th>score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>20</td>\n",
       "      <td>1305</td>\n",
       "      <td>4816</td>\n",
       "      <td>28</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>48</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>70</td>\n",
       "      <td>59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>30</td>\n",
       "      <td>831</td>\n",
       "      <td>6544</td>\n",
       "      <td>20</td>\n",
       "      <td>17</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>56</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>65</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>18</td>\n",
       "      <td>994</td>\n",
       "      <td>1089</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>21</td>\n",
       "      <td>0</td>\n",
       "      <td>35</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>80</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "      <td>27</td>\n",
       "      <td>810</td>\n",
       "      <td>6635</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>55</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>63</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>9</td>\n",
       "      <td>20</td>\n",
       "      <td>1517</td>\n",
       "      <td>5804</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>48</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>70</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 26 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   id  team  smv   wip  over_time  incentive  idle_time  idle_men  \\\n",
       "0   0     9   20  1305       4816         28          0         0   \n",
       "1   1     7   30   831       6544         20         17         1   \n",
       "2   2     4   18   994       1089          0          2        21   \n",
       "3   3     6   27   810       6635          0          0         0   \n",
       "4   4     9   20  1517       5804          0          0         0   \n",
       "\n",
       "   no_of_style_change  no_of_workers  ...  department_finishing  \\\n",
       "0                   0             48  ...                     0   \n",
       "1                   0             56  ...                     0   \n",
       "2                   0             35  ...                     0   \n",
       "3                   0             55  ...                     0   \n",
       "4                   0             48  ...                     0   \n",
       "\n",
       "   department_sweing  day_Monday  day_Saturday  day_Sunday  day_Thursday  \\\n",
       "0                  0           0             0           0             0   \n",
       "1                  1           0             0           0             0   \n",
       "2                  0           0             0           0             0   \n",
       "3                  1           0             0           0             0   \n",
       "4                  0           0             0           0             0   \n",
       "\n",
       "   day_Tuesday  day_Wednesday  targeted_score  score  \n",
       "0            0              0              70     59  \n",
       "1            0              0              65     55  \n",
       "2            0              0              80     26  \n",
       "3            0              0              63     31  \n",
       "4            0              0              70     35  \n",
       "\n",
       "[5 rows x 26 columns]"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "44c97fb7-d46d-4eb0-a547-a8f1c6a962eb",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>team</th>\n",
       "      <th>smv</th>\n",
       "      <th>wip</th>\n",
       "      <th>over_time</th>\n",
       "      <th>incentive</th>\n",
       "      <th>idle_time</th>\n",
       "      <th>idle_men</th>\n",
       "      <th>no_of_style_change</th>\n",
       "      <th>no_of_workers</th>\n",
       "      <th>...</th>\n",
       "      <th>quarter_Quarter5</th>\n",
       "      <th>department_finishing</th>\n",
       "      <th>department_sweing</th>\n",
       "      <th>day_Monday</th>\n",
       "      <th>day_Saturday</th>\n",
       "      <th>day_Sunday</th>\n",
       "      <th>day_Thursday</th>\n",
       "      <th>day_Tuesday</th>\n",
       "      <th>day_Wednesday</th>\n",
       "      <th>targeted_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>1183</td>\n",
       "      <td>2764</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>15</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>1183</td>\n",
       "      <td>1798</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "      <td>13</td>\n",
       "      <td>936</td>\n",
       "      <td>2456</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>18</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>19</td>\n",
       "      <td>844</td>\n",
       "      <td>4179</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>34</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>9</td>\n",
       "      <td>3</td>\n",
       "      <td>1183</td>\n",
       "      <td>960</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 25 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   id  team  smv   wip  over_time  incentive  idle_time  idle_men  \\\n",
       "0   0     3    4  1183       2764          0          0         0   \n",
       "1   1     2    3  1183       1798          0          0         0   \n",
       "2   2     6   13   936       2456          0          0         0   \n",
       "3   3     5   19   844       4179          1          0         0   \n",
       "4   4     9    3  1183        960          0          0         0   \n",
       "\n",
       "   no_of_style_change  no_of_workers  ...  quarter_Quarter5  \\\n",
       "0                   0             15  ...                 0   \n",
       "1                   0              9  ...                 0   \n",
       "2                   0             18  ...                 0   \n",
       "3                   0             34  ...                 0   \n",
       "4                   0              8  ...                 0   \n",
       "\n",
       "   department_finishing  department_sweing  day_Monday  day_Saturday  \\\n",
       "0                     0                  0           0             0   \n",
       "1                     0                  0           0             0   \n",
       "2                     0                  0           0             0   \n",
       "3                     0                  1           0             1   \n",
       "4                     0                  0           0             0   \n",
       "\n",
       "   day_Sunday  day_Thursday  day_Tuesday  day_Wednesday  targeted_score  \n",
       "0           0             0            0              0              46  \n",
       "1           0             0            0              0              75  \n",
       "2           0             0            0              0              77  \n",
       "3           0             0            0              0              78  \n",
       "4           0             0            0              1              50  \n",
       "\n",
       "[5 rows x 25 columns]"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "e0ee724f-038c-46dd-85b6-c10c7066d94d",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "id                         0\n",
       "team                       9\n",
       "smv                       20\n",
       "wip                     1305\n",
       "over_time               4816\n",
       "incentive                 28\n",
       "idle_time                  0\n",
       "idle_men                   0\n",
       "no_of_style_change         0\n",
       "no_of_workers             48\n",
       "month                      2\n",
       "quarter_Quarter1           0\n",
       "quarter_Quarter2           0\n",
       "quarter_Quarter3           0\n",
       "quarter_Quarter4           0\n",
       "quarter_Quarter5           0\n",
       "department_finishing       0\n",
       "department_sweing          0\n",
       "day_Monday                 0\n",
       "day_Saturday               0\n",
       "day_Sunday                 0\n",
       "day_Thursday               0\n",
       "day_Tuesday                0\n",
       "day_Wednesday              0\n",
       "targeted_score            70\n",
       "score                     59\n",
       "Name: 0, dtype: int64"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data.iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "63eba107-99eb-4451-a98b-e3cfd76f0263",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "train_data['team_mean_score'] = train_data['team'].map(train_data.groupby('team')['score'].mean())\n",
    "test_data['team_mean_score'] = test_data['team'].map(train_data.groupby('team')['score'].mean())\n",
    "\n",
    "train_data['month_mean_score'] = train_data['month'].map(train_data.groupby('month')['score'].mean())\n",
    "test_data['month_mean_score'] = test_data['month'].map(train_data.groupby('month')['score'].mean())\n",
    "\n",
    "train_data['quarter_sum'] = train_data[['quarter_Quarter1', 'quarter_Quarter2', 'quarter_Quarter3',\n",
    "       'quarter_Quarter4', 'quarter_Quarter5']].sum()\n",
    "test_data['quarter_sum'] = test_data[['quarter_Quarter1', 'quarter_Quarter2', 'quarter_Quarter3',\n",
    "       'quarter_Quarter4', 'quarter_Quarter5']].sum()\n",
    "\n",
    "train_data['quarter_mean'] = train_data[['quarter_Quarter1', 'quarter_Quarter2', 'quarter_Quarter3',\n",
    "       'quarter_Quarter4', 'quarter_Quarter5']].mean()\n",
    "test_data['quarter_mean'] = test_data[['quarter_Quarter1', 'quarter_Quarter2', 'quarter_Quarter3',\n",
    "       'quarter_Quarter4', 'quarter_Quarter5']].mean()\n",
    "\n",
    "train_data['day_sum'] = train_data[['day_Monday', 'day_Saturday', 'day_Sunday',\n",
    "       'day_Thursday', 'day_Tuesday', 'day_Wednesday']].sum()\n",
    "test_data['day_sum'] = train_data[['day_Monday', 'day_Saturday', 'day_Sunday',\n",
    "       'day_Thursday', 'day_Tuesday', 'day_Wednesday']].sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "8abac085-2005-4b09-86bd-ba73c4564fea",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "test_data['score'] = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "e7bc81d5-b3ff-48b0-b452-a8831ad995c8",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[LightGBM] [Warning] Accuracy may be bad since you didn't explicitly set num_leaves OR 2^max_depth > num_leaves. (num_leaves=31).\n",
      "[LightGBM] [Warning] Accuracy may be bad since you didn't explicitly set num_leaves OR 2^max_depth > num_leaves. (num_leaves=31).\n",
      "[LightGBM] [Warning] Auto-choosing row-wise multi-threading, the overhead of testing was 0.005821 seconds.\n",
      "You can set `force_row_wise=true` to remove the overhead.\n",
      "And if memory is not enough, you can set `force_col_wise=true`.\n",
      "[LightGBM] [Info] Total Bins 1233\n",
      "[LightGBM] [Info] Number of data points in the train set: 144000, number of used features: 26\n",
      "[LightGBM] [Info] Start training from score 53.937500\n",
      "[LightGBM] [Warning] Accuracy may be bad since you didn't explicitly set num_leaves OR 2^max_depth > num_leaves. (num_leaves=31).\n",
      "[LightGBM] [Warning] Accuracy may be bad since you didn't explicitly set num_leaves OR 2^max_depth > num_leaves. (num_leaves=31).\n",
      "[LightGBM] [Warning] Accuracy may be bad since you didn't explicitly set num_leaves OR 2^max_depth > num_leaves. (num_leaves=31).\n",
      "[LightGBM] [Warning] Auto-choosing row-wise multi-threading, the overhead of testing was 0.005912 seconds.\n",
      "You can set `force_row_wise=true` to remove the overhead.\n",
      "And if memory is not enough, you can set `force_col_wise=true`.\n",
      "[LightGBM] [Info] Total Bins 1233\n",
      "[LightGBM] [Info] Number of data points in the train set: 144000, number of used features: 26\n",
      "[LightGBM] [Info] Start training from score 53.937500\n",
      "[LightGBM] [Warning] Accuracy may be bad since you didn't explicitly set num_leaves OR 2^max_depth > num_leaves. (num_leaves=31).\n",
      "[LightGBM] [Warning] Accuracy may be bad since you didn't explicitly set num_leaves OR 2^max_depth > num_leaves. (num_leaves=31).\n",
      "[LightGBM] [Warning] Accuracy may be bad since you didn't explicitly set num_leaves OR 2^max_depth > num_leaves. (num_leaves=31).\n",
      "[LightGBM] [Warning] Auto-choosing row-wise multi-threading, the overhead of testing was 0.005916 seconds.\n",
      "You can set `force_row_wise=true` to remove the overhead.\n",
      "And if memory is not enough, you can set `force_col_wise=true`.\n",
      "[LightGBM] [Info] Total Bins 1233\n",
      "[LightGBM] [Info] Number of data points in the train set: 144000, number of used features: 26\n",
      "[LightGBM] [Info] Start training from score 53.937500\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] Accuracy may be bad since you didn't explicitly set num_leaves OR 2^max_depth > num_leaves. (num_leaves=31).\n"
     ]
    }
   ],
   "source": [
    "model = lgb.LGBMRegressor(max_depth=10)\n",
    "model.fit(train_data.drop(['id', 'score'], axis=1), train_data['score'])\n",
    "test_data['score'] += model.predict(test_data.drop(['id', 'score'], axis=1))\n",
    "\n",
    "model = lgb.LGBMRegressor(max_depth=7, min_child_samples=4)\n",
    "model.fit(train_data.drop(['id', 'score'], axis=1), train_data['score'])\n",
    "test_data['score'] += model.predict(test_data.drop(['id', 'score'], axis=1))\n",
    "\n",
    "model = lgb.LGBMRegressor(max_depth=5, random_state=233)\n",
    "model.fit(train_data.drop(['id', 'score'], axis=1), train_data['score'])\n",
    "test_data['score'] += model.predict(test_data.drop(['id', 'score'], axis=1))\n",
    "\n",
    "test_data['score'] /= 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "3380ee83-e709-4bd0-b6a2-e4cc88610cd4",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "test_data[['id', 'score']].to_csv('lgb.csv', index=None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ff2d8cde-e95d-4a94-97c9-b3068bf12e1d",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3.10"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.10"
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "state": {},
    "version_major": 2,
    "version_minor": 0
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
